package com.rraj.dao.activity.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rraj.common.page.Page;
import com.rraj.common.page.PageQuery;
import com.rraj.dao.activity.ActivityShareDao;
import com.rraj.domain.activity.ActivityShare;
import com.rraj.domain.activity.ActivityShareConditions;
import com.rraj.mapper.activity.ActivityShareMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created by hqm on 2017/6/15.
 */
@Repository
public class ActivityShareDaoImpl implements ActivityShareDao {

    @Resource
    private ActivityShareMapper activityShareMapper;

    @Override
    public PageQuery<ActivityShare> queryActivityShareList(Date startTime, Date endTime, Page page) {
        PageQuery pageQuery = new PageQuery();
        ActivityShareConditions conditions = new ActivityShareConditions();
        conditions.createCriteria().andCreateTimeGreaterThanOrEqualTo(startTime).andCreateTimeLessThan(endTime);
        PageHelper.startPage(page.getCurrentPage(),page.getPageSize());
        List<ActivityShare> activityShareList = activityShareMapper.selectByExample(conditions);
        PageInfo<ActivityShare> pageInfo = new PageInfo<>(activityShareList);
        pageQuery.setResult(activityShareList);
        return pageQuery;
    }
}
